﻿
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;

namespace Star.Tools.Excel
{
    /// <summary>
    /// 指定要映射到列的属性的属性
    /// </summary>
    [AttributeUsage(AttributeTargets.Property, Inherited = true, AllowMultiple = false)]
    public class ExcelColumnAttribute : Attribute
    {

        private int defaultWidth = 12;
        /// <summary>
        /// Column index.
        /// </summary>
        public int Index { get; internal set; } = -1;
   
        /// <summary>
        /// 列名
        /// </summary>
        public string ColumnName { get; set; }

        /// <summary>
        /// 列宽:默认10
        /// </summary>
        public int ColumnWidth { get; set; }

        /// <summary>
        /// 列样式
        /// </summary>
        public ExcelCellStyleEnum ExcelCellStyle { get; set; }
        
        public ExcelCellFormat ExcelCellFormat { get; set; }
        /// <summary>
        /// 是否忽视
        /// </summary>
        public bool IsIgnore { get; set; }

        /// <summary>
        /// 
        /// </summary>
        public string Format { get; set; }
        /// <summary>
        /// 默认左对齐，
        /// </summary>
        public ExcelColumnAttribute(string name)
        {
            ColumnName = name;
            ColumnWidth = defaultWidth;
            ExcelCellStyle = ExcelCellStyleEnum.left;
        }
        public ExcelColumnAttribute(string name, ExcelCellStyleEnum cellStyleEnum)
        {
            ColumnName = name;
            ColumnWidth = defaultWidth;
            ExcelCellStyle = cellStyleEnum;
        }
        /// <summary>
        /// 默认左对齐 列名宽度
        /// </summary>
        /// <param name="name"></param>
        /// <param name="width"></param>
        public ExcelColumnAttribute(string name,int  width)
        {
            ColumnName = name;
            ColumnWidth = width;
            ExcelCellStyle = ExcelCellStyleEnum.left;
        }

        /// <summary>
        /// 获取此对象的克隆
        /// </summary>
        /// <returns></returns>
        public ExcelColumnAttribute Clone()
        {
            return (ExcelColumnAttribute)MemberwiseClone();
        }
        /// <summary>
        /// 指定对象索引克隆
        /// </summary>
        /// <param name="index"></param>
        /// <returns></returns>
        public ExcelColumnAttribute Clone(int index)
        {
            var clone = Clone();
            clone.Index = index;
            return clone;
        }


        public bool GetIsIgnore()
        {
            return this.IsIgnore;
        }


    }

  










}